def is_prime(num):
    """
    """
    if num <= 1:
        return False
    if num <= 3:
        return True
    if num % 2 == 0 or num % 3 == 0:
        return False
    i = 5
    while i * i <= num:
        if num % i == 0 or num % (i + 2) == 0:
            return False
        i += 6
    return True


def find_closest_prime(num):
    """
    """
    if is_prime(num):
        return num

    step = 1
    while True:
        if is_prime(num - step):
            return num - step
        if is_prime(num + step):
            return num + step
        step += 1


def convert_to_number(words):
    """
    """
    number_mapping = {
        "zero": 0,
        "one": 1,
        "two": 2,
        "three": 3,
        "four": 4,
        "five": 5,
        "six": 6,
        "seven": 7,
        "eight": 8,
        "nine": 9,
    }

    try:
        number = int("".join(str(number_mapping[word]) for word in words))
        if 100 <= number <= 999:
            return number
        else:
            return "Wrong input"
    except KeyError:
        return "Wrong input"


words = input().split()
number = convert_to_number(words)
if number == "Wrong input":
    print("Wrong input")
else:
    print(find_closest_prime(number))